"""A Composure virtual machine"""

import gtk

class VirtualMachine:
	"A Composure virtual machine"
	name = "Generic Composure VM"
	def __init__(self, window = None):
		#	Create a GTK+ window if there isn't one already
		if window == None:
			def CloseWindow(caller_widget):
				gtk.main_quit()
			self.window = gtk.Window()
			self.window.set_title(self.name)
			self.window.set_position(gtk.WIN_POS_CENTER)
			self.window.set_size_request(600,400)
			self.window.connect('destroy', CloseWindow)
		else:
			self.window = window

		self.IOSystems = [IOSystem()]
		self.setIOMode(0)

	#	IO system functions
	def getIOMode(self):
		"Get the current IO system and it's rock"
		return (self.IOMode, self.IOSystems[IOMode].rock)

	def setIOMode(self, mode, rock = 0):
		"Set the current IO system and rock"
		if len(self.IOSystems) <= mode:
			self.IOMode = 0
		else:
			self.IOMode = mode
		self.IOSystems[self.IOMode].enable(rock)

class IOSystem:
	"A Composure IO system"
	def __init__(self):
		self.rock = 0

	def enable(self, rock = 0):
		"enable this IO system"
		self.rock = rock

	def streamData(self, data):
		"stream data to the IO system"
		pass
